import {
  queryListData,
  queryListCommunityOrderData,
  // queryGetData,
  setSingleLinePrint,
  setMultiLinePrint,
  setSingleLineTransit,
  setMultiLineTransit,
  changeLine,
  setCommunityTransit,
  setCommunityPrint,
  setSinglePrint,
  setCommunityDispatch,
} from '../services/orderProcessing';
import {
  // pretreatmentRemotePageListData,
  pretreatmentRemoteListData,
  pretreatmentRemoteSingleData,
} from '../utils/tools';

export default {
  namespace: 'orderProcessing',

  state: {},

  effects: {
    *list({ payload }, { call, put }) {
      const response = yield call(queryListData, payload);
      yield put({
        type: 'handleListData',
        payload: response,
      });
    },
    *listCommunityOrder({ payload }, { call, put }) {
      const response = yield call(queryListCommunityOrderData, payload);
      yield put({
        type: 'handleListCommunityOrderData',
        payload: response,
      });
    },
    // *get({ payload }, { call, put }) {
    //   const response = yield call(queryGetData, payload);
    //   yield put({
    //     type: 'handleGetData',
    //     payload: response,
    //   });
    // },
    *setSingleLinePrint({ payload }, { call, put }) {
      const response = yield call(setSingleLinePrint, payload);
      yield put({
        type: 'handleSingleLinePrintData',
        payload: response,
      });
    },
    *setMultiLinePrint({ payload }, { call, put }) {
      const response = yield call(setMultiLinePrint, payload);
      yield put({
        type: 'handleMultiLinePrintData',
        payload: response,
      });
    },
    *setSingleLineTransit({ payload }, { call, put }) {
      const response = yield call(setSingleLineTransit, payload);
      yield put({
        type: 'handleSingleLineTransitData',
        payload: response,
      });
    },
    *setMultiLineTransit({ payload }, { call, put }) {
      const response = yield call(setMultiLineTransit, payload);
      yield put({
        type: 'handleMultiLineTransitData',
        payload: response,
      });
    },
    *changeLine({ payload }, { call, put }) {
      const response = yield call(changeLine, payload);
      yield put({
        type: 'handleChangeLineData',
        payload: response,
      });
    },
    *setCommunityTransit({ payload }, { call, put }) {
      const response = yield call(setCommunityTransit, payload);
      yield put({
        type: 'handleCommunityTransitData',
        payload: response,
      });
    },
    *setCommunityPrint({ payload }, { call, put }) {
      const response = yield call(setCommunityPrint, payload);
      yield put({
        type: 'handleCommunityPrintData',
        payload: response,
      });
    },
    *setSinglePrint({ payload }, { call, put }) {
      const response = yield call(setSinglePrint, payload);
      yield put({
        type: 'handleSinglePrintData',
        payload: response,
      });
    },
    *setCommunityDispatch({ payload }, { call, put }) {
      const response = yield call(setCommunityDispatch, payload);
      yield put({
        type: 'handleCommunityDispatchData',
        payload: response,
      });
    },
  },

  reducers: {
    handleListData(state, action) {
      const d = action.payload;
      const v = pretreatmentRemoteListData(d);

      return {
        ...state,
        data: v,
      };
    },
    handleListCommunityOrderData(state, action) {
      const d = action.payload;
      const v = pretreatmentRemoteListData(d);

      return {
        ...state,
        data: v,
      };
    },
    // handleGetData(state, action) {
    //   const d = action.payload;
    //   const v = pretreatmentRemoteSingleData(d);

    //   return {
    //     ...state,
    //     data: v,
    //   };
    // },
    handleSingleLinePrintData(state, action) {
      const d = action.payload;
      const v = pretreatmentRemoteSingleData(d);

      return {
        ...state,
        data: v,
      };
    },
    handleMultiLinePrintData(state, action) {
      const d = action.payload;
      const v = pretreatmentRemoteSingleData(d);

      return {
        ...state,
        data: v,
      };
    },
    handleSingleLineTransitData(state, action) {
      const d = action.payload;
      const v = pretreatmentRemoteSingleData(d);

      return {
        ...state,
        data: v,
      };
    },
    handleMultiLineTransitData(state, action) {
      const d = action.payload;
      const v = pretreatmentRemoteSingleData(d);

      return {
        ...state,
        data: v,
      };
    },
    handleChangeLineData(state, action) {
      const d = action.payload;
      const v = pretreatmentRemoteSingleData(d);

      return {
        ...state,
        data: v,
      };
    },
    handleCommunityTransitData(state, action) {
      const d = action.payload;
      const v = pretreatmentRemoteSingleData(d);

      return {
        ...state,
        data: v,
      };
    },
    handleCommunityPrintData(state, action) {
      const d = action.payload;
      const v = pretreatmentRemoteSingleData(d);

      return {
        ...state,
        data: v,
      };
    },
    handleSinglePrintData(state, action) {
      const d = action.payload;
      const v = pretreatmentRemoteSingleData(d);

      return {
        ...state,
        data: v,
      };
    },
    handleCommunityDispatchData(state, action) {
      const d = action.payload;
      const v = pretreatmentRemoteSingleData(d);

      return {
        ...state,
        data: v,
      };
    },
  },
};
